< previous page page_477 next page >

Page 477
when one of the data points is very far from the grid location. In that case, the value at that location is deemphasized so that it cannot influence the result too greatly.
e10a6a0a59f035e870d90cca05b85fce.gif
' Create the grid values for display.
'
' Dx and Dz tell how far apart to make the grid
' lines.
Public Sub InitializeGrid(ByVal Dx As Single, _
     ByVal Dz As Single)
Dim Xmin As Single
Dim Xmax As Single
Dim Zmin As Single
Dim Zmax As Single
Dim NumX As Integer
Dim NumZ As Integer
Dim wid As Single
Dim hgt As Single
Dim i As Integer
Dim j As Integer
Dim X As Single
Dim Y As Single
Dim Z As Single
Dim best_i(1 To 4) As Integer
Dim num_close As Integer

    ' Find the X and Z data bounds.
    Xmin = Data(1).coord(1)
    Xmax = Xmin
    Zmin = Data(1).coord(3)
    Zmax = Zmin
    For i = 2 To NumPts
        If Xmin > Data(i).coord(1) Then _
            Xmin = Data(i).coord(1)
        If Xmax < Data(i).coord(1) Then _
            Xmax = Data(i).coord(1)
        If Zmin > Data(i).coord(3) Then _
            Zmin = Data(i).coord(3)
        If Zmax < Data(i).coord(3) Then _
            Zmax = Data(i).coord(3)
    Next i

    ' Set the data boundaries.
    wid = Xmax - Xmin
    hgt = Zmax - Zmin
    NumX = wid / Dx + 1
    NumZ = hgt / Dz + 1
    X = (wid - NumX * Dx) / 2
    Z = (hgt - NumZ * Dz) / 2
    Xmin = Xmin - X
    Xmax = Xmax + X

 
< previous page page_477 next page >